package com.woniuxy.oldmanapi.mapper;

import com.woniuxy.oldmanapi.entity.Food;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

@Repository
public interface FoodMapper extends Mapper<Food> {
    List<Food> initSelectAllByCons(String name);

    @Update("update food set foodStatus = #{status} where id = #{id}")
    void modifyFoodStatus(@Param("id") Integer id, @Param("status") Integer status);

    List<Food> selectFoodByReId(int id);

    @Delete("delete from recipe_food where food_Id = #{foodId} and recipe_Id = #{recipeId}")
    void deleteFoodByRecipeId(@Param("foodId") Integer foodId, @Param("recipeId") Integer recipeId);

    List<Food> selectAllByStatus(String name);

    @Insert("insert into recipe_food  (food_Id , recipe_id) values (#{foodId},#{recipeId} )")
    void addFoodByRecipeId(@Param("foodId") Integer foodId, @Param("recipeId") Integer recipeId);

    @Update("update recipe set recipeStatus = 1 where id =#{id}")
    void modifyStatusById(Integer id);

    @Delete("delete from recipe_food where  recipe_id = #{id}")
    void deleteAllFoodByRecipeId(Integer recipeId);
}